<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<!DOCTYPE HTML>
<html lang="zh-CN">
    <head>
        <meta charset="utf-8">
        <%@ include file="/WEB-INF/views/include/head.jsp"%> 
        <link rel="stylesheet" href="${ctxStatic}/css/DateTimePicker.css">
        <link rel="stylesheet" href="${ctxStatic}/css/layerSm.css">
        <script src="${ctxStatic}/DateTimePicker/DateTimePicker.js"></script>
        <script type="text/javascript">
	          var windowH= window.innerHeight
	                              ||document.doucumentElement.clientHeight
	                              ||document.body.clientHeight
	                     $('.middle').css('height',windowH-40);
	          $(document).ready(function(){
	            $("#dtBox1").DateTimePicker({
	                  dateFormat:"yyyy-MM-dd",
	                  parentElement:".timeBox",
	              });
	           });
	          //保存方法
	          var saveForm={
	                t:null,
	                save:function(t){
	                    $(t).attr("disabled",true);
	                    this.t=t;
	                          // 验证
	                          $("#inputForm").validate({
	                              submitHandler: function() {
	                                  // 格式化，去除逗号
	                                  formUnFormat($("#inputForm"));
	                                  
	                                  // 从表单中获取值
	                                  var params = $("#inputForm").serialize();
	                                     // 调用后台方法
	                                     $.post("${ctx}/material/mywarehouse/saveAlert",params,function(result){
	                                          // 提示信息
	                                          tipParent(result.message);
	                                          // 返回状态
	                                          if(result.statusCode==STATUSCODEOK){
	                                              $(saveForm.t).attr("disabled",false);
	                                              // 刷新页面
	                                              window.parent.frames[0].location.reload();
	                                              // 关闭页面
	                                              closeWin(); 
	                                            }else{
	                                                $(saveForm.t).attr("disabled",false);
	                                            }
	                                       },'json'); 
	                                  },
	                                  fail: function(element,e) {  
	                                      $(saveForm.t).attr("disabled",false);
	                                  }
	                          });
	                          // 添加表单
	                          $("#inputForm").submit(); 
	                      }
	                  }
        </script>
    </head>
    <body>
        <div class="myshop clearfix">
            <!-- 预警数量 -->
            <p class="myshoptop fl"><spring:message code="myWarehouseAlertQuantity"/></p>
            <div class="fr">
                <div class="topBtnClose" onclick="closeWin()">
                    <img src="${ctxStatic}/images/btn-close.png">
                </div>
            </div>
        </div>
        <form id="inputForm" method="post">
        <input type="hidden"  name="id" value="${material.id}"/>
        <input type="hidden"  name="materialAlert.version" value="${material.materialAlert.version}"/>
        <input type="hidden"  name="materialAlert.materialId" value="${material.materialAlert.materialId}"/>
        <input type="hidden"  name="materialAlert.factoryId" value="${material.materialAlert.factoryId}"/>
        <input type="hidden"  name="materialAlert.materialAlertId" value="${material.materialAlert.materialAlertId}"/>
            <div class="middle myshop_middle ware">
                <div class="clearfix" style="height:170px;">
                    <div class="ch fl">
                        <div class="data clearfix">
                            <!-- 物料名称 -->
                            <p class="data_id"><spring:message code="myWarehouse_name_edit"/></p>
                            <p class="rtname fl" data-toggle="tooltip" title="${material.materialNameCn}">${material.materialNameCn}</p>
                        </div>
                        <div class="data clearfix">
                            <!-- 预警开始日期 -->
                            <p class="data_id"><spring:message code="myWarehouse_alert_startDate_show"/></p>
                            <div class="timeBox timeBoxSm">
                                 <input type="text"  id="materialAlertStartDate" style="width: 200px; background-position: 172px 5px;" name="materialAlert.materialAlertStartDate" data-field="date" maxlength="50" class="form-control time" readonly value="<fmt:formatDate value="${material.materialAlert.materialAlertStartDate}" pattern="yyyy-MM-dd"/>">
                            </div>
                        </div>
                        <div class="data clearfix">
                            <!-- 物料编号 -->
                            <p class="data_id"><spring:message code="myWarehouse_code_edit"/></p>
                            <p class="rtname fl">${material.materialCode}</p>
                        </div>
                        <div class="clearfix">
                            <!-- 适用季节 -->
                            <p class="data_id"><spring:message code="myWarehouse_season_edit"/></p>
                            <p class="rtname fl">${fns:getDictName(material.materialSeason)}</p>
                        </div>
                    </div>
                    <div class="ch fr">
                        <div class="data clearfix">
                            <!-- 预警数量-->
                            <p class="data_id" style=""><spring:message code="myWarehouse_alert_quantity_show"/></p>
                            <input type="tel" class="form-control" style="width: 200px; " name="materialAlert.materialAlertQuantity" value="<fmt:formatNumber value="${material.materialAlert.materialAlertQuantity}" pattern="#,##0.00#"/>"  onfocus="unFormat(this)"   onblur="formatNumber(this)" data-rule-integerDecimalmax="7.3"   data-msg-integerDecimalmax="<spring:message code="myWarehouse_pleaseInputAlertQuantity"/>" >
                            ${fns:getDictName(material.materialUnitCd)}
                        </div>
                        <div class="data clearfix">
                            <!-- 预警结束日期-->
                            <p class="data_id" style=""><spring:message code="myWarehouse_alert_endDate_show"/></p>
                            <div class="timeBox timeBoxSm">
                                 <input type="text" style="width: 200px; background-position: 172px 5px;" data-rule-compareDate="#materialAlertStartDate" data-msg-compareDate="<spring:message code="myMaterial_StartDate_Over"/>" name="materialAlert.materialAlertEndDate" data-field="date" maxlength="50" class="form-control time" readonly value="<fmt:formatDate value="${material.materialAlert.materialAlertEndDate}" pattern="yyyy-MM-dd"/>"> 
                            </div>
                        </div>
                        <div class=" clearfix">
                            <!-- 备注 -->
                            <p class="data_id"><spring:message code="myWarehouse_remarks_edit"/></p>
                            <p class="rtname fl" data-toggle="tooltip" title="${material.remarks}">${material.remarks}</p>
                        </div>
                    </div>
                </div>
                <div class="twobtn" style="margin-top:80px;">
                    <div class="onebtn clearfix">
                        <shiro:hasPermission name="material:mywarehouse:edit">
                            <button type="button" class="btn save fl" onclick="saveForm.save(this)"><spring:message code="myWarehouse_save"/></button>
                        </shiro:hasPermission>
                    </div>
                </div>
            </div>
            <div id="dtBox1"></div>
        </form>
    </body>
</html>
